package com.hxkj.controller;

import com.hxkj.domain.po.LabelExt;
import com.hxkj.domain.po.LabelManagement;
import com.hxkj.domain.po.LabelUsageInfo;
import com.hxkj.domain.vo.LabelManagementVO;
import com.hxkj.service.LabelConfService;
import com.platform.common.dispatcher.util.ResultStructUtils;
import com.platform.common.domain.result.ParameterDataStruct;
import com.platform.common.domain.result.ResultDataStruct;
import com.platform.common.domain.result.ResultMessageStruct;
import com.platform.common.domain.result.ResultPageStruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;

@RestController
@RequestMapping(value = "/label")
public class LabelController {

    private static final Logger LOGGER = LoggerFactory.getLogger(LabelController.class);

    @Autowired
    private LabelConfService labelConfService;

    /**
     * @Description 获取标签列表
     * @param parameterDataStruct
     * @return
     */
    @RequestMapping(value = "/getLabelList")
    public Callable<ResultPageStruct<LabelManagementVO>> getLabelList(@RequestBody ParameterDataStruct<LabelManagement> parameterDataStruct){
        return () -> ResultStructUtils.buildResultPageStruct(labelConfService.getLabelList(parameterDataStruct.getData() == null ?
                new LabelManagement() : parameterDataStruct.getData(), parameterDataStruct.getPageTo()), "param=value");
                //labelConfService.getLabelList(labelManagement);
    }

    /**
     * 获取单个标签的详细内容
     * @param labelManagement
     * @return
     */
    @RequestMapping(value = "/getLabelInfo")
    public Callable<ResultDataStruct<LabelManagement>> getLabelInfo(@RequestBody LabelManagement labelManagement){
        return () -> labelConfService.get(labelManagement);
    }

    /**
     * 新增标签
     * @param map
     * @return
     */
    @RequestMapping(value = "/save")
    public Callable<ResultMessageStruct> save(@RequestBody Map<String, Object> map){
        return () -> labelConfService.save(map);
    }

    /**
     * 新增标签
     * @param labelManagement
     * @return
     */
    @RequestMapping(value = "/saveLabel")
    public Callable<ResultMessageStruct> saveLabel(@RequestBody LabelManagement labelManagement){
        return () -> labelConfService.saveLabel(labelManagement);
    }

    /**
     * 修改标签
     * @param map
     * @return
     */
    @RequestMapping(value = "/modifyLabel")
    public Callable<ResultMessageStruct> modifyLabel(@RequestBody Map<String, Object> map){
        return () -> labelConfService.modify(map);
    }

    /**
     * 修改标签
     * @param labelIds
     * @return
     */
    @RequestMapping(value = "/deleteLabel")
    public Callable<ResultMessageStruct> deleteLabel(@RequestBody String labelIds){
        System.out.println(labelIds);
        return () -> labelConfService.remove(labelIds);
    }

    @RequestMapping(value = "/editLabelPlus")
    public Callable<ResultMessageStruct> editLabelPlus(@RequestBody Map<String, Object> map){
        return () -> labelConfService.editLabelPlus(map);
    }


    /****************************标签扩展表业务处理*************************************/

    /**
     * @Description 获取标签列表
     * @param labelExt
     * @return
     */
    @RequestMapping(value = "/getLabelExtList")
    public Callable<ResultDataStruct<List<LabelExt>>> getLabelExtList(@RequestBody LabelExt labelExt){
        return () -> labelConfService.getLabelExt(labelExt);
    }

    /**
     * 新增标签
     * @param labelExt
     * @return
     */
    @RequestMapping(value = "/saveLabelExt")
    public Callable<ResultMessageStruct> saveLabelExt(@RequestBody LabelExt labelExt){
        return () -> labelConfService.saveLabelExt(labelExt);
    }

    /**
     * 修改标签
     * @param labelExt
     * @return
     */
    @RequestMapping(value = "/modifyLabelExt")
    public Callable<ResultMessageStruct> modifyLabelExt(@RequestBody LabelExt labelExt){
        return () -> labelConfService.modifyLabelExt(labelExt);
    }

    /**
     * 修改标签
     * @param labelExt
     * @return
     */
    @RequestMapping(value = "/deleteLabelExt")
    public Callable<ResultMessageStruct> deleteLabelExt(@RequestBody LabelExt labelExt){
        return () -> labelConfService.removeLabelExt(labelExt);
    }


    /****************************标签用法表业务处理*************************************/

    /**
     * @Description 获取标签列表
     * @param labelUsageInfo
     * @return
     */
    @RequestMapping(value = "/getLabelUsageInfoList")
    public Callable<ResultDataStruct<List<LabelUsageInfo>>> getLabelUsageInfoList(@RequestBody LabelUsageInfo labelUsageInfo){
        return () -> labelConfService.getLabelUsage(labelUsageInfo);
    }

    /**
     * 新增标签
     * @param labelUsageInfo
     * @return
     */
    @RequestMapping(value = "/saveLabelUsageInfo")
    public Callable<ResultMessageStruct> saveLabelUsageInfo(@RequestBody LabelUsageInfo labelUsageInfo){
        return () -> labelConfService.saveLabelUsage(labelUsageInfo);
    }

    /**
     * 修改标签
     * @param labelUsageInfo
     * @return
     */
    @RequestMapping(value = "/modifyLabelUsageInfo")
    public Callable<ResultMessageStruct> modifyLabelUsageInfo(@RequestBody LabelUsageInfo labelUsageInfo){
        return () -> labelConfService.modifyLabelUsage(labelUsageInfo);
    }

    /**
     * 修改标签
     * @param labelUsageInfo
     * @return
     */
    @RequestMapping(value = "/deleteLabelUsageInfo")
    public Callable<ResultMessageStruct> deleteLabelUsageInfo(@RequestBody LabelUsageInfo labelUsageInfo){
        return () -> labelConfService.removeLabelUsage(labelUsageInfo);
    }
}
